﻿Public Class QuanLyNha

    Private Sub QuanLyNha_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim bang As DataTable = KiemTraNha_BUS.LoadQuanLyNha
        DataGridView1_QuanLyNha.DataSource = bang
        DataGridView1_QuanLyNha.AutoResizeColumns()
    End Sub

    Private Sub btnXoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXoa.Click
        Dim i As Integer
        If MessageBox.Show("Bạn có chắc chắn muốn xóa dòng này không?", "xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
            i = DataGridView1_QuanLyNha.CurrentRow.Cells(0).FormattedValue.ToString()
            KiemTraNha_BUS.XoaQuanLyNha(i)
            Dim bang As DataTable = KiemTraNha_BUS.LoadQuanLyNha()
            DataGridView1_QuanLyNha.DataSource = bang
            DataGridView1_QuanLyNha.AutoResizeColumns()

        End If
    End Sub

    Private Sub btnCapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCapNhat.Click
        Dim nha As New KiemTraNha_DTO()
        If MessageBox.Show("có chắt chắn bạn muốn cập nhật dòng này không?", "xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
            nha.MaThe = DataGridView1_QuanLyNha.CurrentRow.Cells(0).FormattedValue.ToString()
            nha.TenNguoiChoThue = DataGridView1_QuanLyNha.CurrentRow.Cells(1).FormattedValue.ToString()
            nha.Trangthai = DataGridView1_QuanLyNha.CurrentRow.Cells(2).FormattedValue.ToString()
            nha.TenNguoiThue = DataGridView1_QuanLyNha.CurrentRow.Cells(3).FormattedValue.ToString()
            'nha.NgayKiemTra = DataGridView1_QuanLyNha.CurrentRow.Cells(4).FormattedValue.ToString()'
            nha.TenQL = DataGridView1_QuanLyNha.CurrentRow.Cells(4).FormattedValue.ToString()
            KiemTraNha_BUS.UpdateKiemTraNha(nha)
        End If
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
    End Sub
End Class